const mysql = require('mysql2/promise');

async function createTestDatabase() {
  try {
    const connection = await mysql.createConnection({
      host: process.env.DB_HOST || 'localhost',
      user: process.env.DB_USERNAME || 'root',
      password: process.env.DB_PASSWORD || 'root',
      port: process.env.DB_PORT || 3306,
    });

    await connection.query(
      'CREATE DATABASE IF NOT EXISTS aiessay_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'
    );
    console.log('✅ 测试数据库 aiessay_test 创建成功');

    await connection.end();
    process.exit(0);
  } catch (error) {
    console.error('❌ 创建测试数据库失败:', error.message);
    process.exit(1);
  }
}

createTestDatabase();


